/** 
Copyright (c) 2010, Sheikh Abdul Wahid Ahmed
Details @ http://extremecodeworld.codeplex.com/license
**/

using System;
using System.Web.SessionState;
using System.Web;

namespace EXtremecode.Common
{
	/// <summary>
	/// Summary description for SessionRepository.
	/// </summary>
	public class SessionRepository
	{
		private static SessionRepository singleton=new SessionRepository();
		SessionRepository(){}
		public static SessionRepository Instance
		{
			get
			{
				if(singleton==null)
				{
					singleton=new SessionRepository();
				}
				return singleton;
			}
		}
		
		public object this[string key]
		{
			get
			{
				return	HttpContext.Current.Session["SessionRepository" + key];
			}
			set
			{
				if(HttpContext.Current.Session["SessionRepository" + key]==null)
				{
					HttpContext.Current.Session.Add("SessionRepository" + key,value);
				}
				else
				{
					HttpContext.Current.Session["SessionRepository" + key]=value;
				}
			}
		}

		public IUserProfile UserProfile
		{
			get
			{
				return this[Constants.USER_PROFILE] as IUserProfile; 
			}
			set
			{
				this[Constants.USER_PROFILE] = value;
			}
		}
	}
}
